from django.db import models

# Create your models here.


class AppInfo(models.Model):
    user = models.ForeignKey(to="user.User", verbose_name="用户", on_delete=models.CASCADE)
    title = models.CharField(max_length=64, verbose_name="App名称")
    index_url = models.CharField(max_length=64, verbose_name="主页路由")
    conf_url = models.CharField(max_length=64, verbose_name="配置路由")
    menu_dict = models.TextField(max_length=1024, verbose_name="路由字典")
    top = models.BooleanField(default=False, verbose_name="是否置顶")
    infor = models.CharField(max_length=64, verbose_name="项目简介")
    cover = models.URLField(max_length=256, verbose_name="封面照片")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "APP信息"
        verbose_name_plural = verbose_name


class CoverImage(models.Model):
    image = models.ImageField(upload_to="./cover_image")

    def __str__(self):
        return self.image.url

    class Meta:
        verbose_name = "封面上传"
        verbose_name_plural = verbose_name

#
# class AppConf(models.Model):
#     app = models.ForeignKey(to="AppInfo", verbose_name="APP", on_delete=models.CASCADE)
#     conf = models.TextField(max_length=1024, verbose_name="路由字典")
#
#     def __str__(self):
#         return self.app.title
#
#     class Meta:
#         verbose_name = "APP配置"
#         verbose_name_plural = verbose_name


    """
    [
        {
            "app_info": {"eng_name":"SCHOOL", "chi_name": "学校"},
            "label_info": [
                {"eng_name":"STUDENT", "chi_name": "学生信息"},
                {"eng_name":"COLLEGE", "chi_name": "学院信息"}
            ]
        },
        {
            "app_info": {"eng_name":"USER", "chi_name": "用户信息"},
            "label_info": [
                {"eng_name":"NAME", "chi_name": "学生姓名"},
                {"eng_name":"AGE", "chi_name": "学生年龄"},
                {"eng_name":"CLASS", "chi_name": "学生班级"}
            ]
        }
    ]
    """